package org.whale.springcloud.eureka.user.client.application;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@EnableEurekaClient
@EnableConfigurationProperties
@ComponentScan(basePackages = "org.whale.springcloud.eureka.user.client")
public class EurakeUserClientApplication {

  private static final Logger logger = LoggerFactory.getLogger(EurakeUserClientApplication.class);

  // 启动的时候要注意，由于我们注入了RestTemplate，所以启动的时候需要实例化该类的一个实例
  @Autowired private RestTemplateBuilder builder;

  // 使用RestTemplateBuilder来实例化RestTemplate对象，spring默认已经注入了RestTemplateBuilder实例
  @Bean
  public RestTemplate restTemplate() {
    return builder.build();
  }

  public static void main(String[] args) {
    SpringApplication.run(EurakeUserClientApplication.class, args);

    logger.info("***********user client start*********");
  }
}
